package com.example.demo.controller;

import com.example.demo.domain.Student;
import com.example.demo.repository.StudentRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HelloController {
    private Logger logger = LoggerFactory.getLogger(HelloController.class);
    @Autowired
    StudentRepository studentRepository;


//    @GetMapping(value = "/hello")
//    public String hello() {
//        return "hello!";
//    }

    @GetMapping(value = "/all")
    public List<Student> findall() {
        return studentRepository.findAll();
    }


    /**
     * 测试hello
     * @return
     */
    @GetMapping(value = "/hello")
    public String hello(Model model) {
        model.addAttribute("name", "Dear");
        return "hello";
    }
}
